package cn.terys.terystransactionclient;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import cn.emagsoftware.ui.ToastManager;
import cn.emagsoftware.ui.staticmanager.StaticManager;
import cn.terys.terystransactionclient.zxing.CaptureActivity;

public class BarcodeInputActivity extends BaseActivity
{

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        if (!WelcomeActivity.IS_APP_RUNNING)
        {
            StaticManager.restartAppWhenDalvikRecycled(this, WelcomeActivity.class);
            return;
        }
        setContentView(R.layout.barcodeinput);
        setTitle(R.string.barcodeinput_title);

        final EditText barcode = (EditText) findViewById(R.id.barcode);

        Button confirm = (Button) findViewById(R.id.confirm);
        confirm.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                // TODO Auto-generated method stub
                final String barcodeStr = barcode.getText().toString();
                if (TextUtils.isEmpty(barcodeStr))
                {
                    ToastManager.showLong(BarcodeInputActivity.this, R.string.barcodeinput_confirm_empty);
                    return;
                }
                Intent intent = new Intent(BarcodeInputActivity.this, BarcodeConfirmActivity.class);
                intent.putExtra(CaptureActivity.INTENT_EXTRANAME_BARCODE, barcodeStr);
                startActivity(intent);
            }
        });
        Button cancel = (Button) findViewById(R.id.cancel);
        cancel.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                // TODO Auto-generated method stub
                finish();
            }
        });

    }

}